<template>
  <el-select v-model="value" placeholder="请选择语言" style="margin:0 10px;" @change="onChange">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value"
    />
  </el-select>
</template>

<script>
import cookies from 'js-cookie'

export default {
  name: 'ChangeLang',
  data() {
    return {
      options: [{
        label: '中文',
        value: 'zh'
      }, {
        label: 'English',
        value: 'en'
      }],
      value: cookies.get('lang') || 'zh'
    }
  },

  created() {

  },

  methods: {
    onChange() {
      cookies.set('lang', this.value)
      this.$i18n.locale = this.value
      this.$router.go(0)
    }
  }
}
</script>

<style scoped>

</style>
